// service的出口
import zybw from './request'
import { BASE_URL, TIME_OUT } from './config'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const ZYBW = new zybw({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  interceptors: {
    requestInterceptor: (config) => {
      NProgress.start()

      // const token = sessionStorage.getItem('token')
      // const userName = sessionStorage.getItem('tokenName')
      // const token2 =  'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiLnn7PlrrbluoTluILmmKXoi5fnp43lrZDnu4_okKXpg6g6YXBwIiwiaWF0IjoxNzIxODc0ODAwLCJleHAiOjcyMDE3MjE4NzQ4MDB9.UuYNuwebnJq-jtrG_ThOa9rMdvhvFolQFsdIIqrDj-Q7pIKwbAVRx6VGO5G8f_NxYX0Vkf5A6Kxyt8PP2TfqHg'
      //
      // if (token2 && config.headers) {
      //   config.headers.Authorization = `${token2}`
      //   config.headers.userName = `${userName}`
      //
      // }
      return config
    },
    requestInterceptorCatch: (err) => {
      return err
    },
    responseInterceptor: (res) => {
      NProgress.done()
      return res
    },
    responseInterceptorCatch(error) {

      return error
    }
  }
})


export default ZYBW
